﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcProject.Models.TeamContractBean>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    内部承包协议
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% using (Html.BeginForm())
       {%>
    <h2>
        内部承包协议</h2>
    <div>
        <div class="editor-label">
            所属项目名称
            <%: Html.DropDownList("projectId", ViewData["projectinfos"] as SelectList, "---全部项目---")%>
            所属班组名称
            <%: Html.DropDownList("teamId", ViewData["teams"] as SelectList, "---先选择项目---")%>
            <input type="submit" value="查询" />
        </div>
    </div>
    <table>
        <tr>
            <th>
                合同类型
            </th>
            <th>
                合同名称
            </th>
            <th>
                合同开始时间
            </th>
            <th>
                合同结束时间
            </th>
            <th>
                合同金额
            </th>
            <th>
                创建人
            </th>
            <th>
                创建时间
            </th>
            <th>
            </th>
        </tr>
        <% if (Model != null) foreach (var item in Model)
               { %>
        <tr>
            <td>
                班组合同
            </td>
            <td>
                <%: item.ContractName %>
            </td>
            <td>
                <%: String.Format("{0:g}", item.ContractStartDate) %>
            </td>
            <td>
                <%: String.Format("{0:g}", item.ContractEndDate) %>
            </td>
            <td>
                <%: item.ContractMoney %>
            </td>
            <td>
                <%: item.CreateUserName %>
            </td>
            <td>
                <%: String.Format("{0:g}", item.CreateDate) %>
            </td>
            <td>
                <%: Html.ActionLink("编辑", "Edit", new { id=item.ContractId }) %>
                |
                <%: Html.ActionLink("详细信息", "Details", new { id = item.ContractId, projectId = Request["projectId"]??"0", teamId = item.ForeignerId })%>
                |
                <%: Html.ActionLink("删除", "Delete", new { id=item.ContractId })%>
                |
                <%: Html.ActionLink("成本核算", "../MaterialUseRecord/TeamIndex", new { projectId = Request["projectId"] ?? "0", teamId = item.ForeignerId })%>
            </td>
        </tr>
        <% } %>
        <% } %>
    </table>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#projectId").change(function () { GetTeams() });
        });

        function GetTeams() {
            $("#teamId").empty();
            var url = "../ContractInfo/GetTeamsByProjectId/" + $("#projectId").val();
            $.getJSON(url, function (data) {
                $.each(data, function (i, item) {
                    $("<option></option>")
                                        .val(item["TeamId"])
                                        .text(item["TeamName"])
                                        .appendTo($("#teamId"));
                });
            }); 
        }
    </script> 
</asp:Content>
